-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x-pack/filebeat/input/{cel,httpjson}: fix PEM key validation #38405
Conversation
Pinging @elastic/security-service-integrations (Team:Security-Service Integrations) |
Previously the validation was attempting to parse the PEM text as a key and was also attempting to parse the data as the wrong kind of key.
_, err := x509.ParsePKCS1PrivateKey([]byte(o.OktaJWKPEM)) | ||
blk, rest := pem.Decode([]byte(o.OktaJWKPEM)) | ||
if rest := bytes.TrimSpace(rest); len(rest) != 0 { | ||
return fmt.Errorf("PEM text has trailing data: %s", rest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a check for blk == nil
is warranted if it is going to check for extra data in rest
.
And to be safe against logging key material, I would omit rest
from the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data in rest
is partially orthogonal to the nilness of blk
because of the bytes.TrimSpace
call, but I have guarded against a nil deref.
💚 Build Succeeded
History
cc @efd6 |
💚 Build Succeeded
History
cc @efd6 |
💚 Build Succeeded
History
cc @efd6 |
💚 Build Succeeded
History
cc @efd6 |
💚 Build Succeeded
History
cc @efd6 |
💚 Build Succeeded
History
cc @efd6 |
💚 Build Succeeded
History
cc @efd6 |
💚 Build Succeeded
History
cc @efd6 |
💔 Build Failed
Failed CI StepsHistory
cc @efd6 |
💔 Build Failed
Failed CI StepsHistory
cc @efd6 |
@efd6 Should the windows build failure be a cause of concern here ? |
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Previously the validation was attempting to parse the PEM text as a key and was also attempting to parse the data as the wrong kind of key. (cherry picked from commit c29075e)
Previously the validation was attempting to parse the PEM text as a key and was also attempting to parse the data as the wrong kind of key. (cherry picked from commit c29075e)
… key validation (#38406) * x-pack/filebeat/input/{cel,httpjson}: fix PEM key validation (#38405) Previously the validation was attempting to parse the PEM text as a key and was also attempting to parse the data as the wrong kind of key. (cherry picked from commit c29075e) * remove irrelevant changelog entries --------- Co-authored-by: Dan Kortschak <dan.kortschak@elastic.co>
Proposed commit message
Previously the validation was attempting to parse the PEM text as a key and was also attempting to parse the data as the wrong kind of key.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
Related issues
Use cases
Screenshots
Logs